package com.inwavetech.os.util.field;

import android.widget.TextView;

/**
 * Created by jgskin on 2/14/14.
 */
public abstract class BaseTextField implements Field {

    protected final TextView view;

    public BaseTextField(TextView view) {
        this.view = view;
    }

    @Override
    public boolean isValid() {
        // clear previous errors
        view.setError(null);

        if (view.getText().toString().matches("")) {
            view.setError("O valor não deve estar vazio");

            return false;
        }

        return true;
    }

    @Override
    public Object getValue() {
        return view.getText().toString();
    }

}
